package com.lh.pospi.x_store.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lh.pospi.x_store.R;
import com.lh.pospi.x_store.modle.BrandBean;
import com.lh.pospi.x_store.modle.BrandEntity;

import java.util.List;

import cn.ittiger.indexlist.adapter.IndexStickyViewAdapter;

public class IndexBrandAdapter extends IndexStickyViewAdapter<BrandBean> {
    private Context mContext;
    public IndexBrandAdapter(Context mContext,List<BrandBean> originalList) {
        super(originalList);
        this.mContext = mContext;
    }

    @Override
    public RecyclerView.ViewHolder onCreateIndexViewHolder(ViewGroup parent) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.indexsticky_item_index, parent, false);
        return new IndexViewHolder(view);
    }

    @Override
    public RecyclerView.ViewHolder onCreateContentViewHolder(ViewGroup parent) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.indexsticky_item_contact, parent, false);
        return new ContentViewHolder(view);
    }

    @Override
    public void onBindIndexViewHolder(RecyclerView.ViewHolder holder, int position, String indexName) {
        IndexViewHolder indexViewHolder = (IndexViewHolder) holder;
        indexViewHolder.mTextView.setText(indexName);

    }

    @Override
    public void onBindContentViewHolder(RecyclerView.ViewHolder holder, int position, BrandBean itemData) {
        ContentViewHolder contentViewHolder = (ContentViewHolder) holder;
        contentViewHolder.mName.setText(itemData.getName());

    }
    class IndexViewHolder extends RecyclerView.ViewHolder {
        TextView mTextView;

        public IndexViewHolder(View itemView) {

            super(itemView);
            mTextView = (TextView) itemView.findViewById(R.id.tv_index);
        }
    }

    class ContentViewHolder extends RecyclerView.ViewHolder {
        TextView mName;

        public ContentViewHolder(View itemView) {

            super(itemView);
            mName = (TextView) itemView.findViewById(R.id.tv_name);

        }
    }

}
